export default function createElement(type, props, ...children) {
  const childElements = [].concat(...children).reduce((result,child) => {
    if (child !== false && child !== true && child !== null) {
      if (child instanceof Object) {
        result.push(child)
      } else {
        result.push(createElement('text', { textContent: child }))
      }
    }
    return result
  },[])

  // 没有对false、true、null做处理前
  // const childElements = [].concat(...children).map(child => {
  //   if (child instanceof Object) {
  //     return child
  //   } else {
  //     return createElement('text', {textContent:child})
  //   }
  // })
  // 返回virtualDOM对象，其实就是个js对象
  return {
    type,
    props: Object.assign({ children: childElements }, props),
    children: childElements
  }
}